package com.york.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


@Component("animal")
// 相当于配置文件中 <bean id="animal" class="当前注解的类"/>
public class Animal {

//    @Autowired
//    @Qualifier(value = "cat2")
    @Resource
    private Cat cat;

//    @Autowired
//    @Qualifier(value = "dog2")
    @Resource
    private Dog dog;
    private String name;
    public  String author =  "周瑜";

    public Cat getCat() {
        return cat;
    }

//    public void setCat(Cat cat) {
//        this.cat = cat;
//    }

    public Dog getDog() {
        return dog;
    }

//    public void setDog(Dog dog) {
//        this.dog = dog;
//    }

    public String getName() {
        return name;
    }

//    public void setName(String name) {
//        this.name = name;
//    }

    @Override
    public String toString() {
        return "Animal{" +
                "cat=" + cat +
                ", dog=" + dog +
                ", name='" + name + '\'' +
                '}';
    }
}